package com.AAL.Action;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.interceptor.SessionAware;

import com.AAL.DAO.RequestingDetailDAO;
import com.AAL.DAO.SourcingRequestDAO;
import com.AAL.Model.RequestingDetail;
import com.AAL.Model.SourcingRequest;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
/*
 * Loc DV
 * Create date:30.3.2011
 */
public class RequestingDetailAction extends ActionSupport implements SessionAware{

	
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private SourcingRequest sourcingRequest;
	private RequestingDetail requestDetail;
	private RequestingDetailDAO lnkRequestingDetail;
	private SourcingRequestDAO lnkSourcingRequest;
	private List <RequestingDetail> lstRequestingDetail;
	
	
	

	
	public RequestingDetailAction() {
		
	this.requestDetail=new RequestingDetail();
	this.lnkRequestingDetail=new RequestingDetailDAO();
	this.lnkSourcingRequest=new SourcingRequestDAO();
	this.sourcingRequest=new SourcingRequest();
	}

	/*
	 * view detail Sourcing Request
	 *
	 */
	public String sourcingRequestDetail()
	{
		
		HttpServletRequest request = (HttpServletRequest) ActionContext.getContext().get(ServletActionContext.HTTP_REQUEST);
		try{
		
			String sourcingRequestID = request.getParameter("SourcingRequestID");
			System.out.println(sourcingRequestID);
			this.lstRequestingDetail=this.lnkRequestingDetail.getRequestingDetailBySourcing(sourcingRequestID);
			this.sourcingRequest=this.lnkSourcingRequest.getSourcingRequest(sourcingRequestID);
			
			System.out.println("Test" +lstRequestingDetail.get(0).getRequestingDetailID());
			}
		catch (Exception e) {
			// TODO: handle exception
			return ERROR;
		}
		
		return SUCCESS;
		
	}

	@Override
	public void setSession(Map<String, Object> arg0) {
		// TODO Auto-generated method stub
		
	}

	public SourcingRequest getSourcingRequest() {
		return sourcingRequest;
	}

	public void setSourcingRequest(SourcingRequest sourcingRequest) {
		this.sourcingRequest = sourcingRequest;
	}

	public RequestingDetail getRequestDetail() {
		return requestDetail;
	}

	public void setRequestDetail(RequestingDetail requestDetail) {
		this.requestDetail = requestDetail;
	}

	public List<RequestingDetail> getLstRequestingDetail() {
		return lstRequestingDetail;
	}

	public void setLstRequestingDetail(List<RequestingDetail> lstRequestingDetail) {
		this.lstRequestingDetail = lstRequestingDetail;
	}
	
}
